# include <iostream>
# include <string>
# define N 10
using namespace std;
struct score
{
    string name;
    float Chinese;
    float  math;
    float  English;
};
// 录入学生信息
void input(score per[],int n)
{
    int i = 0;
    for(i;i<n;i++)
    {
        cout << "请输入学生的姓名： " << endl;
        cin >> per[i].name;
        cout << "请按照语、数、外的顺序输入该学生各科成绩： " << endl;
        cin >> per[i].Chinese >> per[i].math  >> per[i].English;
    }
       
}

// 计算总分
void total(score per[],int n,float total[N])
{
    int i = 0;
    for(i;i<n;i++)
    {
        total[i] = per[i].Chinese + per[i].math + per[i].English;
        cout << per[i].name << "的总成绩为：" << total[i] << endl;
    }
}
// 计算单科平均分
void ave(score per[],int n)
{
    int i = 0;
    float ave[3] = {0,0,0};
    for(i;i<n;i++)
    {
        ave[0] += per[i].Chinese;
        ave[1] += per[i].math;
        ave[2] += per[i].English;
    }
    cout << "语文单科平均分：" << ave[0] / n << endl;
    cout << "数学单科平均分：" << ave[1] / n << endl;
    cout << "英语单科平均分：" << ave[2] / n << endl;
}
// 找出总分最大和最小的学生
void stu(score per[],int n,const float total[N])
{
    int i = 0, j, k;
    float max = 0,min = total[0];
    for(i;i<n;i++)
    {
        if(max <= total[i])
        {
            max = total[i];
            j = i;
        }
        if(min >= total[i])
        {
            min = total[i];
            k = i;
        }
    }
    cout << "班级中总分最高的是：" << per[j].name << "--" << "分数为" << max << endl;
    cout << "班级中总分最低的是：" << per[k].name << "--" << "分数为" << min << endl;
}

int main()
{
    float zonshu[N];
    score per[N];
    input(per,N);
    total(per,N,zonshu);
    ave(per,N);
    stu(per,N,zonshu);
    return 0;
}